//RenewInsurePinganModel
//2021-04-22 10:02:30

package models

import (
	"git.900sui.cn/kc/base/common/functions"
	"git.900sui.cn/kc/base/common/models/base"
	"git.900sui.cn/kc/kcgin/orm"
)

//表结构体
type RenewInsurePinganModel struct {
	Model *base.Model
	Field RenewInsurePinganModelField
}

//表字段
type RenewInsurePinganModelField struct {
	T_table           string `default:"renew_insure_pingan"`
	F_id              string `default:"id"`
	F_renew_insure_id string `default:"renew_insure_id"`
	F_acct_name       string `default:"acct_name"`
	F_acct_no         string `default:"acct_no"`
	F_merchant_id     string `default:"merchant_id"`
	F_bank_name       string `default:"bank_name"`
	F_bank_no         string `default:"bank_no"`
	F_bank_card_no    string `default:"bank_card_no"`
	F_ctime           string `default:"ctime"`
}

//初始化
func (r *RenewInsurePinganModel) Init(ormer ...orm.Ormer) *RenewInsurePinganModel {
	functions.ReflectModel(&r.Field)
	r.Model = base.NewModel(r.Field.T_table, ormer...)
	return r
}

//新增数据
func (r *RenewInsurePinganModel) Insert(data map[string]interface{}) int {
	result, _ := r.Model.Data(data).Insert()
	return result
}

func (r *RenewInsurePinganModel) GetByInsureid(insureId int) map[string]interface{} {
	if insureId <= 0 {
		return map[string]interface{}{}
	}

	return r.Model.Where([]base.WhereItem{
		{
			Field: r.Field.F_renew_insure_id,
			Value: insureId,
		},
	}).Find()
}
